/*
 * 作者:熊猫
 * 日期:2017 - 3 - 14 10 - 53 - 29
 *
 */

package net.lainiao.morethread.Chapter6.demo2;

import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.TimeUnit;

/**
 * Created by Administrator on 2017/3/14.
 */
public class Client implements Runnable {
    private LinkedBlockingDeque<String> list;

    public Client(LinkedBlockingDeque<String> list) {
        this.list = list;
    }

    @Override
    public void run() {
        for (int i = 0; i <3 ; i++) {
            for (int j = 0; j < 5; j++) {
                String request=i+":"+j;
                try {
                    list.put(request);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("Client Request :"+request);
            }
            try {
                TimeUnit.SECONDS.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        System.out.println("Client is End! ===="+list.size());
    }
}
